import Doc from '~/components/layout/docs'
import Link from '~/components/text/link'
import Note from '~/components/text/note'
import Caption from '~/components/text/caption'
import { InlineCode } from '~/components/text/code'

export const meta = {
  title: 'Frequently Asked Questions',
  description: 'A list of frequently asked questions relating to deployments.',
  editUrl: 'pages/docs/v2/platform/frequently-asked-questions.mdx',
  lastEdited: '2020-01-28T19:55:40.000Z'
}

## Missing Public Directory

If your project contains a `package.json` file with a `build` [script](https://docs.npmjs.com/misc/scripts), and no `now.json` configuration, it is expected to output its static files into a directory named `public`, at the root of the project, when the `build` [script](https://docs.npmjs.com/misc/scripts) is executed.

<Note type="warning">
  If you are using an{' '}
  <Link href="/docs/v2/build-step/#optimized-frameworks">
    optimized framework
  </Link>
  , you must use the default output directory provided by the framework.
</Note>

You are seeing this error because your setup did not satisfy the above constraint.

To resolve this error, configure your project to place its static output files into a `public` directory, at the root of your project, when the `build` [script](https://docs.npmjs.com/misc/scripts) from your `package.json` file is invoked.

For example, this is how your `package.json` file might look:

```json
{
  "scripts": {
    "build": "[my-framework] build"
  }
}
```

<Caption>
  An example <InlineCode>build</InlineCode> script in a{' '}
  <InlineCode>package.json</InlineCode> file.
</Caption>

If you are seeing this error with a similar `build` script already, you may need to adjust the command to direct its static output files into the `public` directory instead.

<Note>
  Consult your framework's documentation to understand how to specify the build
  output directory.
</Note>

Depending on your framework, the option for this might be called `--output`, `--out`, `--output-dir` or similar:

```json
{
  "scripts": {
    "build": "[my-framework] build --output public"
  }
}
```

<Caption>
  An example <InlineCode>build</InlineCode> script in a{' '}
  <InlineCode>package.json</InlineCode> file that specifies the output
  directory.
</Caption>

Once you have done this, the error will disappear since the output will be the expected directory, `public`.

## Missing Build Script

If your project contains a `package.json` file, no `api` directory, and no `now.json` configuration, it is expected to provide a `build` [script](https://docs.npmjs.com/misc/scripts) that performs a static build of your frontend and outputs it to a `public` directory at the root of your project.

When properly configured, your `package.json` file would look similar to this:

```json
{
  "scripts": {
    "build": "[my-framework] build --output public"
  }
}
```

<Caption>
  An example <InlineCode>build</InlineCode> script in a{' '}
  <InlineCode>package.json</InlineCode> file that specifies the output
  directory.
</Caption>

Once you have defined the `build` [script](https://docs.npmjs.com/misc/scripts), this error will disappear. Furthermore, it will not be displayed if you are using `package.json` purely to provide dependencies for your Serverless Functions located inside the `api` directory.

## Platform Version Detection

[Now CLI](/download) will automatically upgrade your deployment to the latest platform version if you create a new project or if your project meets certain criteria. In order for this to work, you must:

- Remove any Dockerfile.
- Remove the `type` property from your `now.json` file.
- Remove the `start` script from your `package.json` file.
- Remove the `server.js` file from the root of your project.

It is possible to opt out of this behavior by creating a `now.json` file with a `version` property.

If you are yet to upgrade to the latest platform version, please read our [upgrade guide](https://zeit.co/guides/migrate-to-zeit-now/).

## Green Energy Policy

ZEIT works with multiple cloud partners in order to provide services to end users.

The Serverless approach is an energy-efficient alternative to traditional servers because your code runs only on-demand.

For more information on our cloud partners' Green energy policies, we recommend viewing their documentation:

- [AWS Sustainability Timeline](https://aws.amazon.com/about-aws/sustainability/sustainability-timeline/)
- [Google Cloud Sustainability](https://cloud.google.com/sustainability/)
- [Microsoft Environmental Sustainability](https://www.microsoft.com/en-us/corporate-responsibility/sustainability)

## What can I deploy with ZEIT Now?

ZEIT Now is best at deploying technologies that can be served over HTTP and distributed through our CDN network:

- Static websites and static generators (React, Vue, Angular, etc)
- Code that renders HTML on the server-side
- API endpoints that query databases or web APIs and return dynamic data

In general, most popular technologies and languages already have [quickstarts](/docs/v2/introduction#quickstarts) or [guides](/guides) you can start taking advantage of today.

export default ({ children }) => <Doc meta={meta}>{children}</Doc>

export const config = {
  amp: 'hybrid'
}
